package com.dingding.common.core.util;

import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Properties;

import org.apache.log4j.Logger;

/**
 * 
 * @ClassName: PropertiesUtil
 * @Description:配置文件读取工具类
 * @author cheshaowei
 * @date 2015-8-27 下午04:45:31
 * 
 */
public class PropertiesUtil {

	private static final Logger log = Logger.getLogger(PropertiesUtil.class);

	/**
	 * @Title: getValue
	 * @Description:
	 * @author cheshaowei
	 * @throws
	 */
	public static String getValue(String key) {
		Properties prop = new Properties();
		InputStreamReader inputStream = null;
		try {
			log.info(System.getProperty("user.dir"));
			inputStream = new InputStreamReader(PropertiesUtil.class.getResourceAsStream("/config.properties"),
					"UTF-8");
			prop.load(inputStream);
			String value = prop.getProperty(key);
			return value;
		} catch (IOException e) {
			log.error("读取配置文件出现异常！ 类：PropertiesUtil 方法：getValue()");
			return null;
		} finally {
			if (inputStream != null) {
				try {
					inputStream.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
	}

}
